﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.Intrinsics.Arm;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LvcChong
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void btnOrderQuery_Click(object sender, EventArgs e)
        {
            ShowContent(new FormOrderQuery());
        }

        private void btnUserOrder_Click(object sender, EventArgs e)
        {
            ShowContent(new FormUserOrderQuery());
        }

        private void btnUserList_Click(object sender, EventArgs e)
        {
            ShowContent(new FormUserQuery());
        }

        private void btnVehicleList_Click(object sender, EventArgs e)
        {
            ShowContent(new FormVehicleQuery());
        }

        private void btnPromotion_Click(object sender, EventArgs e)
        {
            ShowContent(new FormPromotionQuery());
        }

        private void ShowContent(Form form)
        {
            if (this.MdiChildren.Any(x => x.Name == form.Name))
            {
                this.MdiChildren.First(x => x.Name == form.Name).Activate();
                return;
            }

            form.AutoScaleMode = AutoScaleMode.Inherit;
            form.MdiParent = this;
            form.Show();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            ShowContent(new FormOrderQuery());
        }

        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}
